Skip to content

[build] Do not modify assemblies in the NuGet package cache - #12450

Merged
jonathanpeppers merged 3 commits into
mainfrom
jonathanpeppers-test-nuget-cache-resources
Aug 20, 2026
Merged

[build] Do not modify assemblies in the NuGet package cache#12450
jonathanpeppers merged 3 commits into
mainfrom
jonathanpeppers-test-nuget-cache-resources

Conversation

@jonathanpeppers

@jonathanpeppers jonathanpeppers commented Aug 19, 2026

Copy link
Copy Markdown
Member

Description

Android builds must treat the NuGet global package cache as read-only. However, satellite *.resources.dll files from NuGet packages were included in ResolvedAssemblies and passed to AssemblyModifierPipeline using their original package-cache paths.

When marshal methods were enabled, _RunAfterILLinkAdditionalSteps ran this pipeline in place. Even unchanged assemblies had their timestamps updated, and concurrent builds could fail when they attempted to write the same cached file.

Exclude satellite resource assemblies from the post-link modifier input only when the pipeline operates in place. The assemblies remain in the normal resolved-assembly flow, so they are still packaged, and non-in-place post-link processing is unchanged.

Add a regression test using Humanizer.Core.es from the public dotnet-public feed. It locks the package's resource assemblies and verifies that the build neither writes to them nor changes their timestamps.

Tests

  • BuildDoesNotModifyNuGetPackageCache
  • CheckIncludedAssemblies(True, CoreCLR)

Fixes #11022

Add a red regression test for #11022 using Humanizer satellite assemblies from dotnet-public.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d50a004c-7088-4372-a35a-a824c74118be
Skip satellite resource assemblies when the post-link pipeline operates in place, while retaining them in the packaging item flow.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d50a004c-7088-4372-a35a-a824c74118be
@jonathanpeppers jonathanpeppers changed the title [tests] Reproduce NuGet package cache modification [build] Avoid modifying NuGet satellite assemblies Aug 19, 2026
@jonathanpeppers
jonathanpeppers marked this pull request as ready for review August 19, 2026 19:44
Copilot AI lite review requested due to automatic review settings August 19, 2026 19:44
@jonathanpeppers jonathanpeppers changed the title [build] Avoid modifying NuGet satellite assemblies [build] Do not modify assemblies in the NuGet package cache Aug 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR prevents Android builds from mutating *.resources.dll satellite assemblies located in the NuGet global package cache when the post-link AssemblyModifierPipeline runs in-place (marshal-methods path), avoiding timestamp changes and potential concurrent-build file lock collisions.

Changes:

  • Filters @(ResolvedAssemblies) so satellite *.resources.dll are excluded only from the in-place post-link modifier inputs.
  • Keeps satellite assemblies in the normal assembly flow so they can still be packaged as expected.
  • Adds a regression test that restores Humanizer satellite assemblies, locks them, and verifies they aren’t modified by the build.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets Excludes *.resources.dll from the in-place AssemblyModifierPipeline input list to avoid writing into NuGet package-cache paths.
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs Adds a regression test intended to ensure builds don’t modify locked NuGet satellite assemblies.

Comment thread src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
Delete the incremental post-link stamp before exercising the marshal-method path and verify that the target recreates it.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d50a004c-7088-4372-a35a-a824c74118be
@jonathanpeppers
jonathanpeppers merged commit 66d3f74 into main Aug 20, 2026
44 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers-test-nuget-cache-resources branch August 20, 2026 14:00
jonathanpeppers added a commit that referenced this pull request Aug 21, 2026
…rites (#12463)

## Summary

- Backports #11552 (`286b38c3109cd39b5512fcfd23530e7cbba7db6f`) so incremental `BuildArchive` updates retain unchanged JAR resources, replace updated entries, and remove stale entries correctly.
- Backports #12450 (`66d3f745f5b231e5c82b78ee9fcf105f883dd9bd`) so in-place post-link processing excludes satellite assemblies from the NuGet package cache, while preserving normal packaging and non-in-place behavior.

## RC1 justification

These are narrowly scoped customer-facing correctness and reliability fixes. They prevent stale or incorrect APK contents during incremental builds, prevent mutation of NuGet package-cache assemblies, and avoid concurrent-build XAAMP7024 failures caused by writes to shared cached satellite assemblies.

There are no public API changes and no dependency changes.

## Validation

- PASS: `BuildArchiveTests` — 4 passed, 0 failed.
- PASS: `Xamarin.Android.Build.Tests` and its product dependencies compiled successfully with the host .NET 11 SDK after building the existing bootstrap task prerequisites.
- PASS: `Xamarin.Android.Common.targets` XML validation.
- The `BuildDoesNotModifyNuGetPackageCache` integration test compiled and started, but could not execute its nested app build because this checkout does not contain the repo-local SDK at `bin\Debug\dotnet\dotnet`; CI should provide full-build coverage.

Upstream references: #11552 and #12450.

Co-authored-by: Šimon Rozsíval <simon@rozsival.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XAAMP7024 - Build error due to IOException in AssemblyModifierPipeline

3 participants